home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / PowerMac vs 68K Rules Example / powerMac.r < prev    next >
Encoding:
Text File  |  1996-09-30  |  11.8 KB  |  398 lines  |  [TEXT/MPS ]

  1. //
  2. //    powerMac.r
  3. //
  4. //        This example demonstrates usage of the Easy and Custom Install frameworks 
  5. //        to create a customized installation depending on whether the target machine 
  6. //        is a Power Macintosh or a 68000 CPU machine.
  7. //
  8. //        All files are installed to folder "PowerMac Rules Example:" on root folder 
  9. //        of selected target volume for the installation.
  10. //
  11. //        NOTE: This example uses Gestalt calls to determine the CPU of the target 
  12. //        machine of the installation. Some machines with STP cards in them are 
  13. //        actually both PowerMac and 68K, but via a Control Panel the user can select 
  14. //        which machine they want their Mac to behave as. This example script will 
  15. //        install the appropriate modules during Easy Install for whichever CPU the 
  16. //        target machine is currently set up as. Because of the STP upgrade card 
  17. //        situation, most scriptwriters will actually want to include all possible 
  18. //        installation scenarios under Custom Install. 
  19. //
  20. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  21. //
  22.  
  23.  
  24. #include "InstallerTypes.r"
  25.  
  26.  
  27. // constants for Gestalt call to determine whether PowerMac or 68K CPU
  28. #define gestaltSystemType            'sysa'  // tells Gestalt to check CPU
  29. #define gestalt68Ksysa                1        // tells Gestalt to look for 68K CPU's
  30. #define gestaltPPCsysa                2        // tells Gestalt to look for PowerMac CPU's
  31.  
  32. // constants for packages, comments, comment text
  33. #define     kPowerMacPackage    100
  34. #define     k68000Package        200
  35. #define     kSeperatorLine        9999
  36.  
  37.  
  38. // • easy install setup
  39.  
  40. // easy install framework uses ID other than 765 or 766
  41. // recommended to always use ID 764
  42. resource 'infr' (764) {
  43.     format0 {{
  44.         // execute first true rule, if none are true then return false
  45.         pickFirst, { 700, 800 },    // check CPU version, if PowerMac then
  46.                                     // install PowerMac, otherwise install
  47.                                     // 68K version
  48.     }}
  49. };
  50.  
  51. // rule that adds Power Macintosh version file to Easy Install
  52. resource 'inrl' (700) {
  53.     format0 {{
  54.         // this returns false unless CPU is Power Macintosh
  55.         CheckGestalt{ gestaltSystemType, { gestaltPPCsysa }},
  56.         
  57.         // if Power Macintosh CPU add that package
  58.         AddPackages{{ kPowerMacPackage }},
  59.         AddUserDescription{ "Install the PowerMac Example File to \"PowerMac Rules Example\" folder." },
  60.     }}
  61. };
  62.  
  63. // rule that adds 68K version file to Easy Install
  64. resource 'inrl' (800) {
  65.     format0 {{
  66.         
  67.         // if not a PowerMac, add the 68000 CPU package
  68.         AddPackages{{ k68000Package }},
  69.         AddUserDescription{ "Install the 68K Example File to \"PowerMac Rules Example\" folder." },
  70.     }}
  71. };
  72.  
  73.  
  74. // • custom install setup
  75.  
  76. // custom install framework always uses ID of 766
  77. resource 'infr' (766) {
  78.     format0 {{
  79.         pickAll, { 1000 },        // give choices of PowerMac and 68K
  80.     }}
  81. };
  82.  
  83. // rule that adds both PowerMac and 68K packages
  84. resource 'inrl' (1000) {
  85.     format0 {{
  86.         
  87.         // add both PowerMac and 68K packages to Custom Install selections
  88.         AddCustomItems{{ kPowerMacPackage, kSeperatorLine, k68000Package }},
  89.     }}
  90. };
  91.  
  92.  
  93. // • packages
  94.  
  95. // Power Macintosh
  96. resource 'inpk' ( kPowerMacPackage ) {
  97.     format0 {
  98.         showsOnCustom,            // if a subpackage, show in Custom Install
  99.         removable,                // include as a removeable item
  100.         dontForceRestart,        // don't make user reboot after installation
  101.         kPowerMacPackage,        // ID of package comments ( 'inpc' ), defined below
  102.         0,                        // Package size ( if 0, filled in by ScriptCheck )
  103.         
  104.         "PowerMac - Example File to \"PowerMac Rules Example\" folder.",        
  105.                                 // Custom Install selection text
  106.                                 
  107.                                 
  108.         {        // Package parts list ( all the stuff to be include in package )
  109.                 // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
  110.                 // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
  111.                                                                 
  112.         'infa', 1075;            // PowerMac file
  113.         },
  114.     }
  115. };
  116.  
  117.  
  118. // seperator line in Custom Install list of options
  119. resource 'inpk' ( kSeperatorLine ) {
  120.     format0 {
  121.         showsOnCustom,            // if a subpackage, show in Custom Install
  122.         
  123.         notRemovable,            // don't allow selection of seperator line 
  124.                                 // for removal
  125.                                 
  126.         dontForceRestart,        // don't make user reboot after installation
  127.         0,                        // no comments for a seperator line
  128.         0,                        // no size for a seperator line
  129.         "-",                    // display a dashed line in Custom Install 
  130.         {    
  131.                                 // parts list is empty for seperator line
  132.         },
  133.     }
  134. };
  135.  
  136. // 68K
  137. resource 'inpk' ( k68000Package ) {
  138.     format0 {
  139.         showsOnCustom,            // if a subpackage, show in Custom Install
  140.         removable,                // include as a removeable item
  141.         dontForceRestart,        // don't make user reboot after installation
  142.         k68000Package,            // ID of package comments ( 'inpc' ), defined below
  143.         0,                        // Package size ( if 0, filled in by ScriptCheck )
  144.         
  145.         "68K - Example File to \"PowerMac Rules Example\" folder.",        
  146.                                 // Custom Install selection text
  147.                                 
  148.                                 
  149.         {        // Package parts list ( all the stuff to be include in package )
  150.                 // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
  151.                 // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
  152.                                 
  153.         'infa', 1070;            // 68K compatable file
  154.         },
  155.     }
  156. };
  157.  
  158.  
  159.  
  160. // • package comments
  161.  
  162. // NOTE: The file that will be installed in either package is an Example File.
  163. // The information detailed below does not actually correspond to 
  164. // the file being installed and is intended only as an example of how to prepare 
  165. // custom package information resources.
  166.  
  167. // FURTHER NOTE: The values that are assigned to the Custom Package Information 
  168. // resource fields do not actually have any effect on the installation and are 
  169. // ignored during installation. They can however assist the user in choosing which 
  170. // packages they would like to include in their Custom Installation or Custom Removal.
  171.  
  172. // The following included file contains the icons for the two package comments.
  173. // The file with the icon resources ( in this case 'icl4' and 'icl8' ) was created
  174. // by opening the owner application of the file to be installed (in this case, 
  175. // SimpleText) within ResEdit. The 'ICN#', 'icl4' and'icl8' icon resources were then  
  176. // copied into a new ResEdit file called "Icons.rsrc" and assigned the resource items 
  177. // an ID of 9128, since their original resource ID's had a value that was illegal 
  178. // for use with 'inpc' resources ( they must be over 1024 ).
  179. // - An alternative to this method is to derez the application and to paste the 
  180. // resulting resource definitions into this script file and to let the Rez command 
  181. // build the icons every time that the installer script is Rezzed. If you happen 
  182. // to forget to include the resources for the icons, ScriptCheck will complain, 
  183. // but you will still be able to use the Rezzed installer script to successfully 
  184. // perform an installation. 
  185. include "Icons.rsrc";
  186.  
  187. resource 'inpc' ( kPowerMacPackage ) {
  188.     format1 {
  189.         8021994,                // sample date ( 08/02/94 )
  190.         403,                    // sample version ( 4.0.3 )
  191.         
  192.         2500 * 1024,            // RAM required for package ( 2.5 megabytes )
  193.         
  194.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  195.                                 // - ID must be greater than 1024
  196.                                 // - resource item in rezzed script file
  197.                                 
  198.         kPowerMacPackage,        // 'TEXT' resource ID of item  
  199.                                 // containing package description
  200.         
  201.     }
  202. };
  203.  
  204. resource 'inpc' ( k68000Package ) {
  205.     format1 {
  206.         8021994,                // sample date ( 08/02/94 )
  207.         403,                    // sample version ( 4.0.3 )
  208.  
  209.         4250 * 1024,            // RAM required for package ( 4.25 megabytes )
  210.         
  211.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  212.                                 // - ID must be greater than 1024
  213.                                 // - resource item in rezzed script file
  214.  
  215.         k68000Package,            // 'TEXT' resource ID of item  
  216.                                 // containing package description
  217.     }
  218. };
  219.  
  220.  
  221. // The following resource items can easily be created manually by creating 'TEXT' 
  222. //  resource items in a file and including that file in this script.
  223. // USE: include "<fileWithTextItem>.rsrc";    
  224. // NOTE : resource includes use "include" instead of "#include" 
  225. //         and are terminated with a semicolon.
  226. data 'TEXT' ( kPowerMacPackage ) {
  227.     "This is some sample text that would describe what the Power Macintosh "
  228.     "package contains."
  229. };
  230.  
  231. data 'TEXT' ( k68000Package ) {
  232.     "This is some sample text that would describe what the 68000 CPU "
  233.     "package contains."
  234. };
  235.  
  236.  
  237.  
  238. // • file atoms
  239.  
  240. // file atom for PowerMac version
  241. resource 'infa' (1075) {
  242.     format1 {
  243.         deleteWhenRemoving,
  244.         deleteWhenInstalling,
  245.         copy,                        
  246.         dontIgnoreLockedFile,
  247.         dontSetFileLocked,
  248.         useSrcCrDateToCompare,        
  249.         srcNeedExist,
  250.         rsrcForkInRsrcFork,
  251.         leaveAloneIfNewer,            
  252.         updateExisting,                
  253.         copyIfNewOrUpdate,
  254.         rsrcFork,
  255.         dataFork,
  256.         0,
  257.         0x0,
  258.         10075,
  259.         {    
  260.             10076, 
  261.             0, 
  262.             0    
  263.         },
  264.         0,                            
  265.         0,
  266.         0,
  267.         "Example File • PowerMac"
  268.     }
  269. };
  270.  
  271. // file atom for 68K version
  272. resource 'infa' (1070) {
  273.     format1 {
  274.         deleteWhenRemoving,
  275.         deleteWhenInstalling,
  276.         copy,                        
  277.         dontIgnoreLockedFile,
  278.         dontSetFileLocked,
  279.         useSrcCrDateToCompare,        
  280.         srcNeedExist,
  281.         rsrcForkInRsrcFork,
  282.         leaveAloneIfNewer,            
  283.         updateExisting,                
  284.         copyIfNewOrUpdate,
  285.         rsrcFork,
  286.         dataFork,
  287.         0,
  288.         0x0,
  289.         10070,
  290.         {    
  291.             10071, 
  292.             0, 
  293.             0    
  294.         },
  295.         0,                            
  296.         0,
  297.         0,
  298.         "Example File • 68K"
  299.     }
  300. };
  301.  
  302.  
  303. // • file specs
  304.  
  305. // target file spec for Example File • PowerMac File
  306. resource 'intf' (10075) {
  307.     format1 {
  308.         noSearchForFile,                 // use default search path
  309.         
  310.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  311.                                         // then a file with a different type
  312.                                         // and creator than those specified
  313.                                         // below will not be replaced.
  314.                                         // If this is set to TypeCrNeedNotMatch
  315.                                         // then type and creator of an existing
  316.                                         // target file are ignored.
  317.         
  318.         // The Type and Creator fields will be used to set the
  319.         // file's Type and Creator when a new file is created. 
  320.         'ttro',                         // TYPE for new file
  321.         'ttxt',                         // CREATOR for new file
  322.         
  323.         0,                                 // finder attribute flags
  324.                                         // filled by ScriptCheck is value is 0
  325.         
  326.         1,                                  // creation date for new file
  327.         1,                                  // modification date for new file
  328.                                         // NOTE: DATE values are filled
  329.                                         // by ScriptCheck if the value is 1
  330.                                             
  331.         0,                                 // search proc ID ( 'insp' ), none used
  332.         
  333.         ":PowerMac Rules Example:Example File • PowerMac" // path to target file
  334.         }
  335.     };
  336.  
  337.  
  338. // source file spec for Example File • PowerMac
  339. resource 'infs' (10076) {
  340.     'ttro',                        // TYPE for file search
  341.     'ttxt',                        // CREATOR for file search
  342.     
  343.     0x1,                        // creation DATE for source file
  344.                                 // ( value of 1, filled in by ScriptCheck
  345.                                 
  346.     noSearchForFile,            // IGNORED in Installer 4.0.x
  347.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  348.     "Disk 1:Example File • PowerMac"    // PATH to source file        
  349. };
  350.  
  351.  
  352. // target file spec for Example File • 68K
  353. resource 'intf' (10070) {
  354.     format1 {
  355.         noSearchForFile,                 // use default search path
  356.         
  357.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  358.                                         // then a file with a different type
  359.                                         // and creator than those specified
  360.                                         // below will not be replaced.
  361.                                         // If this is set to TypeCrNeedNotMatch
  362.                                         // then type and creator of an existing
  363.                                         // target file are ignored.
  364.         
  365.         // The Type and Creator fields will be used to set the
  366.         // file's Type and Creator when a new file is created. 
  367.         'ttro',                         // TYPE for new file
  368.         'ttxt',                         // CREATOR for new file
  369.         
  370.         0,                                 // finder attribute flags
  371.                                         // filled by ScriptCheck is value is 0
  372.         
  373.         1,                                  // creation date for new file
  374.         1,                                  // modification date for new file
  375.                                         // NOTE: DATE values are filled
  376.                                         // by ScriptCheck if the value is 1
  377.                                             
  378.         0,                                 // search proc ID ( 'insp' ), none used
  379.         
  380.         ":PowerMac Rules Example:Example File • 68K" // path to target file
  381.         }
  382.     };
  383.  
  384. // source file spec for Example File • 68K
  385. resource 'infs' (10071) {
  386.     'ttro',                        // TYPE for file search
  387.     'ttxt',                        // CREATOR for file search
  388.     
  389.     0x1,                        // creation DATE for source file
  390.                                 // ( value of 1, filled in by ScriptCheck
  391.                                 
  392.     noSearchForFile,            // IGNORED in Installer 4.0.x
  393.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  394.     "Disk 1:Example File • 68K"        // PATH to source file        
  395. };
  396.  
  397.  
  398.